/*------------------------------------------------------------------------------
--                                                                            --
--       This software is confidential and proprietary and may be used        --
--        only as expressly authorized by a licensing agreement from          --
--                                                                            --
--                            Hantro Products Oy.                             --
--                                                                            --
--      In the event of publication, the following notice is applicable:      --
--                                                                            --
--                   (C) COPYRIGHT 2005 HANTRO PRODUCTS OY                    --
--                            ALL RIGHTS RESERVED                             --
--                                                                            --
--         The entire notice above must be reproduced on all copies.          --
--                                                                            --
--------------------------------------------------------------------------------
--
--  Description : API of 7170 VC-1 Decoder
--
--------------------------------------------------------------------------------
--
--  Version control information, please leave untouched.
--
--  $RCSfile: vc1decapi.h,v $
--  $Date: 2006/09/15 08:51:54 $
--  $Revision: 1.6 $
--
------------------------------------------------------------------------------*/

#ifndef VC1DECAPI_H
#define VC1DECAPI_H

#ifdef __cplusplus
extern "C"
{
#endif

#include "basetype.h"

/*------------------------------------------------------------------------------
    API type definitions
------------------------------------------------------------------------------*/

    /* Return values */
    typedef enum VC1DecRet
    {
        VC1DEC_OK = 0,                /* Operation successful.*/
        VC1DEC_PIC_RDY = 1,           /* Picture decoded.*/
        VC1DEC_NOT_CODED_PIC_RDY = 2, /* Skipped picture decoded.*/
        VC1DEC_FREEZED_PIC_RDY = 3,   /* Picture freezed.*/
        VC1DEC_STRM_PROCESSED = 4,    /* Stream handled, no picture finished.*/

        VC1DEC_PARAM_ERROR = -1,      /* Function called with invalid
                                         parameters. */
        VC1DEC_NOT_INITIALIZED = -3,  /* Attempt to decode with
                                         uninitialized Decoder.*/
        VC1DEC_MEMFAIL = -4,          /* Memory failure. */
        VC1DEC_INITFAIL = -5,         /* Decoder initialization failure.
                                         Right shift is not signed. */
        VC1DEC_METADATA_FAIL = -6,    /* Supplied metadata is in wrong
                                         format */
        VC1DEC_HW_RESERVED = -254,
        VC1DEC_HW_TIMEOUT = -255,
        VC1DEC_HW_BUS_ERROR = -256,
        VC1DEC_SYSTEM_ERROR = -257,
        VC1DEC_DWL_ERROR = -258
    } VC1DecRet;


    /*
    * Container for the metadata of the stream.
    * Contains a wide range of information about the stream, e.g. what kind of
    * tools are needed to decode the stream.
    */
    typedef struct
    {
        u32     maxCodedWidth;  /* Specifies the maximum coded width in
                                   pixels of picture within the sequence.*/
        u32     maxCodedHeight; /* Specifies the maximum coded height in
                                   pixels of picture within the sequence.*/
        u32     vsTransform;    /* Indicates whether variable sized transform
                                   is enabled for the sequence.*/
        u32     overlap;        /* Indicates whether overlap smoothing is
                                   enabled for the sequence. */
        u32     syncMarker;     /* True if there are syncronization markers in
                                   the stream.*/
        u32     quantizer;      /* Indicates quantizer type used for the
                                   sequence. */
        u32     frameInterp;    /* Indicates whether the INTERPFRM flag(which
                                   provides information to display process)
                                   exists in the picture headers.*/
    } VC1DecMetaData;

    /*
    *   Decoder instance is used for identifying subsequent calls to api
    *   functions.
    */
    typedef void *VC1DecInst;

    /*
    *  Decoder input structure.
    *  This is a container to pass data to the Decoder.
    */
    typedef struct
    {

        u8* pStream;           /* Pointer to the video stream. Decoder does
                                  not change the contents of stream buffer.*/
        u32 streamBusAddress;  /* DMA bus address of the input stream */
        u32 streamSize;        /* Number of bytes in the stream buffer.*/
    } VC1DecInput;

    /*
    *   Decoder output structure.
    *   This is a container for Decoder output data like decoded picture and its
    *   dimensions.
    */
    typedef struct
    {
        u32 frameWidth;      /* Width of coded frame in pixels.*/
        u32 frameHeight;     /* Height of coded frame in pixels.*/
        u32 codedWidth;      /* Displayable width of output frame in pixels.*/
        u32 codedHeight;     /* Displayable height of output frame in pixels.*/
        u8* pOutputPicture;  /* Pointer to the decoded picture.*/
        u32 outputPictureBusAddress;  /* DMA bus address of the output pic */
        u32 keyFrame;        /* Indicates whether decoded frame
                                is a key frame. */
    } VC1DecOutput;

    /* Version information. */
    typedef struct
    {
        u32 major;    /* Decoder API major version number. */
        u32 minor;    /* Decoder API minor version number. */
    } VC1DecApiVersion;

    typedef struct
    {
        u32 swBuild;  /* Software build ID */
        u32 hwBuild;  /* Hardware build ID */
    } VC1DecBuild;

    /* decoder  output picture format */
    typedef enum
    {
        VC1DEC_SEMIPLANAR_YUV420 = 0x020001,
        VC1DEC_TILED_YUV420 = 0x020002
    } VC1DecOutFormat;

    typedef struct
    {
        VC1DecOutFormat outputFormat; /* format of the output picture */
    } VC1DecInfo;

/*------------------------------------------------------------------------------
    Prototypes of Decoder API functions
------------------------------------------------------------------------------*/

    VC1DecApiVersion VC1DecGetAPIVersion(void);

    VC1DecBuild VC1DecGetBuild(void);

    VC1DecRet VC1DecInit( VC1DecInst* pDecInst, VC1DecMetaData* pMetaData);

    VC1DecRet VC1DecDecode( VC1DecInst decInst,
                            VC1DecInput* pInput,
                            VC1DecOutput* pOutput);

    void VC1DecRelease(VC1DecInst decInst);

    VC1DecRet VC1DecGetInfo(VC1DecInst decInst, VC1DecInfo * pDecInfo);

    VC1DecRet VC1DecUnpackMetaData( u8 *pBuffer, u32 bufferSize,
                                    VC1DecMetaData *pMetaData );

/*------------------------------------------------------------------------------
    Prototype of the API trace funtion. Traces all API entries and returns.
    This must be implemented by the application using the decoder API!
    Argument:
        string - trace message, a null terminated string
------------------------------------------------------------------------------*/
    void VC1DecTrace(const char *string);

#ifdef __cplusplus
}
#endif

#endif /* VC1DECAPI_H */
